 {literal}
<script type="text/javascript">
$(document).ready(function(){
	
    $('#vitalSignList{/literal}{$ticketId}{literal}').bind('click',function(){
    	{/literal}
    	var selected = $('#vitalSignList{$ticketId} :selected');
    	{literal}
    	if (selected != null) {
    		{/literal}
       		//reset validattion message and textbox border color
   			$('#resultMessage{$ticketId}').css('color', 'green');
   			$('#resultMessage{$ticketId}').html('');
   			$('#vitalSignBps{$ticketId}').css('border-color', '#AAA');
   			$('#vitalSignBpd{$ticketId}').css('border-color', '#AAA');
   			//
	    	$('#vitalSignPulse{$ticketId}').val(selected.attr('vitalSignPusle'));
		    $('#vitalSignBps{$ticketId}').val(selected.attr('vitalSignBps'));
		    $('#vitalSignBpd{$ticketId}').val(selected.attr('vitalSignBpd'));
		    $('#vitalSignRespiratory{$ticketId}').val(selected.attr('vitalSignRespiratory'));
		    $('#vitalSignTemperature{$ticketId}').val(selected.attr('vitalSignTemperature'));
		    $('#vitalSignSp02{$ticketId}').val(selected.attr('vitalSignSp02'));
		    {literal}
    	}
    });
    
    $('#vitalSignList{/literal}{$ticketId}{literal}').bind('change',function(){
    	{/literal}
            var selected = $('#vitalSignList{$ticketId} :selected');
            {literal}
            if (selected != null) {
                {/literal}
                $('#vitalSignPulse{$ticketId}').val(selected.attr('vitalSignPusle'));
                $('#vitalSignBps{$ticketId}').val(selected.attr('vitalSignBps'));
                $('#vitalSignBpd{$ticketId}').val(selected.attr('vitalSignBpd'));
                $('#vitalSignRespiratory{$ticketId}').val(selected.attr('vitalSignRespiratory'));
                $('#vitalSignTemperature{$ticketId}').val(selected.attr('vitalSignTemperature'));
                $('#vitalSignSp02{$ticketId}').val(selected.attr('vitalSignSp02'));
                {literal}
            }
        
    });
   
    $('#vitalSignSave{/literal}{$ticketId}{literal}').bind('click',function(){
                     {/literal}
                     var selectedId = $('#vitalSignList{$ticketId} :selected').val();
                     {literal}
                     if (selectedId != null && $.trim(selectedId) != '') {
                         saveVitalSign({/literal}{$ticketId}{literal},{/literal}{$patientId}{literal}, selectedId);
                                         
                     }        
                         
             });  
    {/literal}
        
   	{literal}
       $('#vitalSignBpd{/literal}{$ticketId}{literal}').blur(function(){
           validateBP($('#vitalSignBps{/literal}{$ticketId}{literal}'), $('#vitalSignBpd{/literal}{$ticketId}{literal}'), $('#resultMessage{/literal}{$ticketId}{literal}')); 
       });
    {/literal}  
          
    addDatePickerTime("#vitalSign{$ticketId}_dd",'#vitalSign{$ticketId}_mm','#vitalSign{$ticketId}_yyyy','#vitalSignTime{$ticketId}',false,false,true);
    {literal}
})
</script>
{/literal}
<table class='dialogTable' cellspacing='0' cellpadding='0' style='width: 100%'>
	<tr>
		<td width="50%">
			<form id="diagnosisForm{$ticketId}">
				<table class="inline" cellspacing='0' cellpadding='0' style='width: 100%'>
					<tr>
						<th colspan="4">{translate}Diagnosis{/translate}</th>
					</tr>
					<tr>
						<td colspan="4"><span id="generalDStatusMessage{$ticketId}" style="font-style: italic; color: red;"></span></td>
					</tr>
					<tr>
						<td style="width: 80px">{translate}Glasgow{/translate}</td>
						<td sltyle='width: 20px'>E</td>
						<td colspan="2">
							<select tabindex="0" style="width: 200px" id="diagnosisGE{$ticketId}" onchange="return changeGCS('{$ticketId}')">
								<option id="empty" value="0">- {translate}Best eye response{/translate} -</option>
								{html_options options=$glasgowEList selected=$generalDiagnosis.enum_glasgow_e}
							</select>
						</td>
					</tr>
					<tr>
						<td rowspan='2' style='text-align: center;'>
							{if $glasgowEVM == 0}
							<span class='label' style='font-size: 2em; font-weight: bold;' id='glasgowEMVSpn{$ticketId}'></span>
							{else}
							<span class='label' style='font-size: 2em; font-weight: bold;' id='glasgowEMVSpn{$ticketId}'>{$glasgowEVM}</span>
							{/if}
						</td>
						<td>V</td>
						<td colspan="2">
							<select style="width: 200px" id="diagnosisGV{$ticketId}" onchange="return changeGCS('{$ticketId}')">
								<option id="empty" value="0">- {translate}Best verbal response{/translate} -</option>
								{html_options options=$glasgowVList selected=$generalDiagnosis.enum_glasgow_v}
							</select>
						</td>
					</tr>
					<tr>
						<td>M</td>
						<td colspan="2">
							<select style="width: 200px" id="diagnosisGM{$ticketId}" onchange="return changeGCS('{$ticketId}')">
								<option id="empty" value="0">- {translate}Best motor response{/translate} -</option>
								{html_options options=$glasgowMList selected=$generalDiagnosis.enum_glasgow_m}
							</select>
						</td>
					</tr>
					<tr>
						<td>{translate}Glucose{/translate} (mmol/L):</td>
						<td></td>
						<td colspan="2">
							<input style="width: 195px" type="text" id="diagnosisGlu{$ticketId}" value="{$generalDiagnosis.glucose}" onkeypress="return allowEnterFloatNum(event,true)">
						</td>
					</tr>
					<tr>
						<td>{translate}Painful{/translate}</td>
						<td></td>
						<td colspan="2" rowspan='2'>
							<table class='inline' cellspacing='0' cellpadding='0'>
								<tr>
									<td title="{translate}No pain{/translate}">
										<label for="painfulLevel1"><img src="{$base_uri}/images/painfullevel/pain_0.png" /></label>							
									</td>
									<td>
										<label for="painfulLevel2"><img src="{$base_uri}/images/painfullevel/pain_2.png" /></label>
									</td>
									<td>
										<label for="painfulLevel3"><img src="{$base_uri}/images/painfullevel/pain_4.png" /></label>
									</td>
									<td>
										<label for="painfulLevel4"><img src="{$base_uri}/images/painfullevel/pain_6.png" /></label>
									</td>
									<td>
										<label for="painfulLevel5"><img src="{$base_uri}/images/painfullevel/pain_8.png" /></label>
									</td>
									<td title="{translate}Extreme pain{/translate}">
										<label for="painfulLevel6"><img src="{$base_uri}/images/painfullevel/pain_10.png" /></label>
									</td>
								</tr>
								<tr>
									<td title="{translate}No pain{/translate}">
										<input id="painfulLevel1" name="diagnosisPainful{$ticketId}" value="0" type="radio" "{if ($generalDiagnosis.enum_painful_status==0)}checked='checked'{/if}" onclick="return changePainLevel('{$ticketId}', 0)" />
									</td>
									<td>
										<input id="painfulLevel2" name="diagnosisPainful{$ticketId}" value="2" type="radio" "{if ($generalDiagnosis.enum_painful_status==2)}checked='checked'{/if}" onclick="return changePainLevel('{$ticketId}', 2)" />
									</td>
									<td>
										<input id="painfulLevel3" name="diagnosisPainful{$ticketId}" value="4" type="radio" "{if ($generalDiagnosis.enum_painful_status==4)}checked='checked'{/if}" onclick="return changePainLevel('{$ticketId}', 4)" />
									</td>
									<td>
										<input id="painfulLevel4" name="diagnosisPainful{$ticketId}" value="6" type="radio" "{if ($generalDiagnosis.enum_painful_status==6)}checked='checked'{/if}" onclick="return changePainLevel('{$ticketId}', 6)" />
									</td>
									<td>
										<input id="painfulLevel5" name="diagnosisPainful{$ticketId}" value="8" type="radio" "{if ($generalDiagnosis.enum_painful_status==8)}checked='checked'{/if}" onclick="return changePainLevel('{$ticketId}', 8)" />
									</td>
									<td>
										<input id="painfulLevel6" name="diagnosisPainful{$ticketId}" value="10" type="radio" "{if ($generalDiagnosis.enum_painful_status==10)}checked='checked'{/if}" title="{translate}Extreme pain{/translate}" onclick="return changePainLevel('{$ticketId}', 10)" />
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td style='text-align: center;'>
							{if $generalDiagnosis.enum_painful_status == 0}
							<span class='label' style='font-size: 2em; font-weight: bold;' id='painLevelSpn{$ticketId}'></span>
							{else}
							<span class='label' style='font-size: 2em; font-weight: bold;' id='painLevelSpn{$ticketId}'>{$generalDiagnosis.enum_painful_status}</span>
							{/if}
						</td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td>
							{translate}Allergy{/translate} &nbsp;&nbsp;
							{if ($generalDiagnosis.allergy == 0)}
							<input type="checkbox" id="diagnosisAllergy{$ticketId}" onclick="return checkAllergy('{$ticketId}')" />
							{else}
							<input type="checkbox" id="diagnosisAllergy{$ticketId}" checked="checked" onclick="return checkAllergy('{$ticketId}')" />
							{/if}
						</td>
						<td>
							{translate}General_1{/translate}
						</td>
						<td>
							{if ($generalDiagnosis.allergy == 0)}
							<input style="width: 160px" type="text" id="diagnosisAllergyDetail{$ticketId}" value="{$generalDiagnosis.general_allergy_detail}" disabled="disabled">
							{else}
							<input style="width: 160px" type="text" id="diagnosisAllergyDetail{$ticketId}" value="{$generalDiagnosis.general_allergy_detail}">
							{/if}
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td>{translate}Drug{/translate}</td>
						<td>
						{if ($generalDiagnosis.allergy == 0)}
							<input style='width: 160px' type='text' id='diagnosisDrugAllergyDetail{$ticketId}' value="{$generalDiagnosis.drug_allergy_detail}" disabled="disabled" />
						{else}
							<input style='width: 160px' type='text' id='diagnosisDrugAllergyDetail{$ticketId}' value="{$generalDiagnosis.drug_allergy_detail}" />
						{/if}
						</td>
					</tr>
					<tr>
						<td>{translate}Doctor{/translate}</td>
						<td></td>
						<td colspan="2">
							<select style="width: 200px" id="emrDoctor{$ticketId}">
								<option id="empty" value="0">{translate}Select doctor{/translate}</option>
								{html_options options=$doctorList selected=$inPatientEmr.doctor_id}
							</select>
						</td>
					</tr>
					<tr>
						<td>{translate}Diagnosis{/translate}</td>
						<td></td>
						<td colspan="2">
							<input style="width: 195px" type="text" id="emrDiagnosis{$ticketId}" value="{$inPatientEmr.diagnosis}">
						</td>
					</tr>
					<tr>
						<td>ICD10 (1st)</td>
						<td><input style='width: 35px' type="text" id="emrICD10Code{$ticketId}" value="{$inPatientEmr.icd10_p_code}" icd10Id='{$inPatientEmr.icd10_id}' /></td>
						<td colspan='2'>
							<input style='width:195px' type='text' id='emrICD10Name{$ticketId}' readonly='readonly' value='{$inPatientEmr.icd10_p_name}' />
							<button type="button" ticketId="{$ticketId}" id="btnPriIcd10{$ticketId}" onclick="javasript:showIcd10List('emrICD10Code{$ticketId}','emrICD10Name{$ticketId}')">...</button>
						</td>
					</tr>
					<tr>
						<td>ICD10 (2nd)</td>
						<td><input style='width: 35px' type="text" id="sndEmrICD10Code{$ticketId}" value="{$inPatientEmr.icd10_s_code}" icd10Id='{$inPatientEmr.s_icd10_id}' /></td>
						<td colspan='2'>
							<input style='width:195px' type='text' id='sndEmrICD10Name{$ticketId}' readonly='readonly' value='{$inPatientEmr.icd10_s_name}' />
							<button type="button" ticketId="{$ticketId}" id="btnPriIcd10{$ticketId}" onclick="javasript:showIcd10List('sndEmrICD10Code{$ticketId}','sndEmrICD10Name{$ticketId}')">...</button>
						</td>
					</tr>
					<tr>
						<td colspan='4'>
							<input type="button" id="diagnosisSave{$ticketId}" ticketId="{$ticketId}" value="{translate}Save{/translate}" onclick="javascript:saveGeneralDiagnosis('{$ticketId}','{$patientId}')">
						</td>
					</tr>
					<tr>
						<td colspan="4">
							<span id="generalDResultMessage{$ticketId}" style="font-style: italic; color: red;"></span>
						</td>
					</tr>
		
				</table>
			</form>
		</td>
		<td style="vertical-align: top;">
			<form id="vitalSignForm{$ticketId}">
				<table class="inline" cellspacing='0' cellpadding='0' style='width: 100%'>
					<tr>
						<th colspan='5'>{translate}Vital sign{/translate}</th>
					</tr>
					<tr>
						<td colspan="5">
							<span id="statusMessage{$ticketId}" style="font-style: italic; color: red;"></span>
						</td>
					</tr>
					<tr>
						<td style="width: 20%">{translate}Diagnosis time{/translate}</td>
						<td colspan="4">
							<input onkeypress="return allowEnterIntegerNum(event,true)"	name="vitalSign{$ticketId}_{$datePart_0}" id="vitalSign{$ticketId}_{$datePart_0}" type="text" value="" style="width: 21px;"/>
							<input onkeypress="return allowEnterIntegerNum(event,true)" name="vitalSign{$ticketId}_{$datePart_1}" id="vitalSign{$ticketId}_{$datePart_1}" type="text" value="" style="width: 21px;"/>
							<input onkeypress="return allowEnterIntegerNum(event,true)" name="vitalSign{$ticketId}_{$datePart_2}" id="vitalSign{$ticketId}_{$datePart_2}" type="text" value="" style="width: 40px;"/>
							<input name="vitalSignTime{$ticketId}" type="text" id="vitalSignTime{$ticketId}" style="width: 40px;"/>
						</td>
					</tr>
					<tr>
						<td colspan='5'>
							<input type="button" id="vitalSignAdd{$ticketId}" ticketId="{$ticketId}" value="{translate}Add{/translate}" onclick="javascript:addVitalSign('{$ticketId}', '{$patientId}')"/>
						</td>
					</tr>
					<tr>
						<td rowspan="5">
							<select tabindex="22" style="width: 160px;" size="13" id="vitalSignList{$ticketId}">
							{foreach from=$listOfVitalSign item=vitalSign key=key}
								<option vitalSignTime="{$vitalSign.examine_time}"
									value="{$vitalSign.vital_sign_id}"
									vitalSignPusle="{$vitalSign.pulse}"
									vitalSignBps="{$vitalSign.blood_presure_s}"
									vitalSignBpd="{$vitalSign.blood_presure_d}"
									vitalSignRespiratory="{$vitalSign.respiratory_rate}"
									vitalSignTemperature="{$vitalSign.temperature}"
									vitalSignSp02="{$vitalSign.sp02}">{$vitalSign.examine_time}
								</option>
							{/foreach}
							</select>
						</td>
						<td>{translate}Pulse{/translate} {translate}(times/min){/translate}:</td>
						<td colspan="2">
							<input style="width: 60px;" type="text" id="vitalSignPulse{$ticketId}" onkeypress="return allowEnterIntegerNum(event,true)"/>
						</td>
					</tr>
					<tr>
						<td>{translate}BP{/translate} (s/d mmHg):</td>
						<td colspan="3">
							<input style="width: 21px;" type="text" id="vitalSignBps{$ticketId}" onkeypress="return allowEnterIntegerNum(event,true)"/><span>/</span>
							<input style="width: 21px;" type="text" id="vitalSignBpd{$ticketId}" onkeypress="return allowEnterIntegerNum(event,true)"/>
						</td>
					</tr>
					<tr>
						<td>{translate}Respiratory rate{/translate}</td>
						<td colspan="2">
							<input style="width: 60px;" type="text" id="vitalSignRespiratory{$ticketId}" onkeypress="return allowEnterIntegerNum(event,true)"/>
						</td>
					</tr>
					<tr>
						<td>{translate}Temperature{/translate}</td>
						<td colspan="2">
							<input style="width: 60px;" type="text" id="vitalSignTemperature{$ticketId}" onkeypress="return allowEnterFloatNum(event,true)"/>
						</td>
					</tr>
					<tr>
						<td>{translate}Sp02{/translate} (%)</td>
						<td colspan="2">
							<input style="width: 60px;" type="text" id="vitalSignSp02{$ticketId}" onkeypress="return allowEnterFloatNum(event,true)"/>
						</td>
					</tr>
					<tr>
						<td>
							<input type="button" id="vitalSignDel{$ticketId}" value="{translate}Del{/translate}" onclick="javascript:delVitalSign('{$ticketId}', '{$patientId}')"/>
						</td>
						<td></td>
						<td>
							<input type="button" id="vitalSignSave{$ticketId}" value="{translate}Save{/translate}"/>
						</td>
					</tr>
					<tr>
						<td colspan="5">
							<span id="resultMessage{$ticketId}" style="font-style: italic; color: red;"></span>
						</td>
					</tr>
				</table>
			</form>
		</td>
	</tr>
</table>